import random
import time

from sort.QuickSort import QuickSort
from sort.Sort import Sort


def test(sort_class: Sort, arr_list):
    print("排序前：{}".format(str(arr_list)))
    sort_class.sort(arr_list)
    print("排序后：{}".format(str(arr_list)))


def test_time(sort_class: Sort, arr_list):
    start_time = time.time()
    sort_class.sort(arr_list)
    end_time = time.time()
    print("{} --- 排序共计耗时{}秒".format(sort_class.__class__.__qualname__, end_time - start_time))


if __name__ == '__main__':
    print()
    # 测试少量数据
    arr_list = [random.randint(0, 1000) for _ in range(10)]
    test(QuickSort(), arr_list)

    # 测试十万级数据测试其效率
    many_arr_list = [random.randint(0, 1000000) for _ in range(100000)]
    test_time(QuickSort(), many_arr_list)
